<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2017/11/8
  Time: 9:39
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>产品退库</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath }/bootstrap/dist/css/bootstrap.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath }/pages/yzl/css/test.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath }/plugins/layui/css/layui.css"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath }/plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath }/bootstrap-table/dist/bootstrap-table.css"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath }/css/toastr.min.css"/>
    <script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery-1.10.2.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath }/bootstrap/dist/js/bootstrap.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath }/bootstrap-table/dist/bootstrap-table.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath }/bootstrap-table/src/locale/bootstrap-table-zh-CN.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath }/plugins/layui/layui.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath }/js/toastr.min.js"></script>
    <script type="text/javascript">toastr.options.positionClass = 'toast-top-center';</script>

    <%--<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>产品退货</title>
    <script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery-1.10.2.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath }/bootstrap/dist/js/bootstrap.js"></script>
    <link rel="stylesheet" href="${pageContext.request.contextPath }/bootstrap/dist/css/bootstrap.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath }/pages/yzl/css/test.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath }plugins/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="${pageContext.request.contextPath }/plugins/font-awesome/css/font-awesome.min.css">
    <script src="${pageContext.request.contextPath }/bootstrap-cb/dist/bootstrap-table.js"></script>
    <link href="${pageContext.request.contextPath }/bootstrap-cb/dist/bootstrap-table.css" rel="stylesheet"/>
    <script src="${pageContext.request.contextPath }/bootstrap-cb/src/locale/bootstrap-table-zh-CN.js"></script>--%>
    <%--<script type="text/javascript" src="${pageContext.request.contextPath }/plugins/layui/layui.js"></script>--%>
    <script type="text/javascript">
        $(function () {

            //1.初始化Table
            var oTable = new TableInit();
            oTable.Init();

            //2.初始化Button的点击事件
            var oButtonInit = new ButtonInit();
            oButtonInit.Init();

        });


        var TableInit = function () {
            var oTableInit = new Object();
            //初始化Table
            oTableInit.Init = function () {
                $('#tb_departments').bootstrapTable({
                    url: '/pages/yzl/data/returnGoods.json',         //请求后台的URL（*）
                    method: 'get',                      //请求方式（*）
                    toolbar: '#toolbar',                //工具按钮用哪个容器
                    striped: true,                      //是否显示行间隔色
                    cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
                    pagination: true,                   //是否显示分页（*）
                    sortable: false,                     //是否启用排序
                    sortOrder: "asc",                   //排序方式
                    queryParams: oTableInit.queryParams,//传递参数（*）
                    sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
                    pageNumber:1,                       //初始化加载第一页，默认第一页
                    pageSize: 10,                       //每页的记录行数（*）
                    pageList: [10, 25, 50, 100],        //可供选择的每页的行数（*）
                    search: true,                       //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
                    strictSearch: true,
                    showColumns: true,                  //是否显示所有的列
                    showRefresh: true,                  //是否显示刷新按钮
                    minimumCountColumns: 2,             //最少允许的列数
                    clickToSelect: true,                //是否启用点击选中行
                    height: 500,                        //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
                    uniqueId: "ID",                     //每一行的唯一标识，一般为主键列
                    showToggle:true,                    //是否显示详细视图和列表视图的切换按钮
                    cardView: false,                    //是否显示详细视图
                    detailView: false,                   //是否显示父子表
                    columns: [{
                        checkbox: true
                    }, /*{
                        field: 'id',
                        title: 'ID'
                    },*/ {
                        field: 'customer',
                        title: '客户'
                    }, {
                        field: 'carType',
                        title: '车种'
                    }, {
                        field: 'pName',
                        title: '品名'
                    }, {
                        field: 'pihao',
                        title: '批号'
                    },{
                        field: 'pNumber',
                        title: '品编'
                    }, {
                        field: 'barCode',
                        title: '条码'
                    }, {
                        field: 'goLibraryquatity',
                        title: '出库数量'
                    },{
                        field: 'goLibrarydate',
                        title: '出库日期',
                    },{
                        field: 'status',
                        title: '状态',
                    },{
                        field: 'dealwith',
                        title: '操作',
                        formatter: function (value, row, index) {
                            var back = index;
                            if(value == 1){
                                return '<a href="#" onclick="refund('+back+')" >退库</a>'
                            }else if(value == 2){
                                return '审核中'
                            }else if(value == 3){
                                return '退库成功'
                            }else if(value == 4){
                                return '<a href="#" onclick="reXq('+back+')" >详情</a>'
                            }


                        }
                    },]
                });
            };

            //得到查询的参数
            oTableInit.queryParams = function (params) {
                var temp = {   //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
                    limit: params.limit,   //页面大小
                    offset: params.offset,  //页码
                    departmentname: $("#txt_search_departmentname").val(),
                    statu: $("#txt_search_statu").val()
                };
                return temp;
            };
            return oTableInit;
        };


        var ButtonInit = function () {

            var oInit = new Object();
            var postdata = {};

            oInit.Init = function () {
                //初始化页面上面的按钮事件
            };
            return oInit;
        };
    </script>
</head>
<body>

<div class="panel-body" style="padding-bottom:0px;">
    <div class="panel panel-default">
        <div class="panel-heading">查询条件</div>
        <div class="panel-body">
            <form id="formSearch" class="form-horizontal">
                <div class="form-group" style="margin-top:15px">
                    <label class="control-label col-sm-1" for="txt_search_departmentname">条码</label>
                    <div class="col-sm-3">
                        <input type="text" class="form-control" id="txt_search_departmentname" value="2017080913140001">
                    </div>

                    <div class="col-sm-4" style="text-align:left;">
                        <button type="button" style="margin-left:50px" id="btn_query" class="btn btn-primary">查询</button>
                    </div>
                </div>
            </form>
        </div>
    </div>

    <%--<div id="toolbar" class="btn-group">
        <button id="btn_add" type="button" class="btn btn-default">
            <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>新增
        </button>
        <button id="btn_edit" type="button" class="btn btn-default">
            <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>修改
        </button>
        <button id="btn_delete" type="button" class="btn btn-default">
            <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>删除
        </button>
    </div>--%>

    <!--        表格           -->
    <table id="tb_departments"></table>



<!--          修改表单       -->
<div class="modal fade" id="myModalUpdate" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myModalLabelUpdate">退库申请填写</h4>
            </div>

            <form class="form-horizontal" role="form">
                <%--<div class="form-group">
                    <label for="type" class="col-sm-2 control-label">类型</label>
                    <div class="col-sm-7">
                        <select class="form-control">
                            <option>原材料</option>
                            <option>易耗品</option>
                            <option>半成品</option>
                        </select>
                    </div>
                </div>--%>

                <div class="form-group">
                    <label for="number" class="col-sm-2 control-label">退货数量</label>
                    <div class="col-sm-7 ">
                        <input type="text" class="form-control" id="numberU">
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-sm-2">选择日期</label>
                    <div class="col-sm-7">
                        <input type="text" name="date" id="date1" lay-verify="date" placeholder="yyyy-mm-dd"
                               autocomplete="off" class="layui-input form-control"
                               onclick="layui.laydate({elem: this})">
                    </div>
                </div>

                <div class="form-group">
                    <label for="spec" class="col-sm-2 control-label">退库原因</label>
                    <div class="col-sm-7">
                        <input type="text" class="form-control" id="specU">
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-sm-2">选择库位</label>
                    <div class="col-sm-7">
                        <select class="form-control">
                            <option>A-1-1</option>
                            <option>A-2-1</option>
                            <option>A-3-1</option>
                            <option>A-2-2</option>
                        </select>
                    </div>
                </div>
            </form>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary">提交申请</button>
            </div>
        </div>
    </div>
</div>

    <!--          不通过详情         -->
    <div class="modal fade" id="xiangqingModel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h4 class="modal-title">驳回详情</h4>
                </div>

                <div>
                    <br>&nbsp;&nbsp;&nbsp;&nbsp;车种:"车种"<br><br>&nbsp;&nbsp;&nbsp;&nbsp;客户:"客户1" <br>
                    <br>&nbsp;&nbsp;&nbsp;&nbsp;品名:"品名"<br><br>&nbsp;&nbsp;&nbsp;&nbsp;品编:"品编" <br>
                    <br>&nbsp;&nbsp;&nbsp;&nbsp;原因:"人为损坏，不予退库"<br><br>
                </div>

                <div class="modal-footer">
                    <%--<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>--%>
                    <button type="button" class="btn btn-primary">重新提交</button>
                </div>
            </div>
        </div>
    </div>

<script>
    $(document).ready(function(){
        $("#btn_add").click(function () {

            var allRows = $("#tb_departments").bootstrapTable("getData");


            console.log("allRows",allRows);

            $('#myModal').modal({
                keyboard: true,
            })
        });
        $("#btn_edit").click(function () {

            if($('#checkbox-id').is(':checked')) {
                console.log(222222222222);
            }

            $('#myModalUpdate').modal({
                keyboard: true,
            })
        });
        $("#btn_delete").click(function () {

            if($('#checkbox-id').is(':checked')) {
                console.log(333333333333);
            }

            $('#myModalDelete').modal({
                keyboard: true,
            })
        });
    });

    function refund(){
        $('#myModalUpdate').modal({
            keyboard: true,
        })
    }

</script>


    <script>
        layui.use(['form', 'layedit', 'laydate'], function() {
            var form = layui.form(),
                layer = layui.layer,
                layedit = layui.layedit,
                laydate = layui.laydate;

            //创建一个编辑器
            var editIndex = layedit.build('LAY_demo_editor');
            //自定义验证规则
            form.verify({
                title: function(value) {
                    if(value.length < 5) {
                        return '标题至少得5个字符啊';
                    }
                },
                pass: [/(.+){6,12}$/, '密码必须6到12位'],
                content: function(value) {
                    layedit.sync(editIndex);
                }
            });

            //监听提交
            form.on('submit(demo1)', function(data) {
                layer.alert(JSON.stringify(data.field), {
                    title: '最终的提交信息'
                })
                return false;
            });
        });

        function reXq(){
            $('#xiangqingModel').modal({
                keyboard: true,
            })

        }

    </script>

</body>
</html>
